<?php
/** 
 * $Source: /cvsroot/pn-commerce/pn-commerce/pntemplates/plugins/function.pncEditItemLink.php,v $
 * $Author: landseer $
 * $Revision: 1.1 $
 * $Date: 2004/06/06 12:58:37 $
 *
 * Type: Function
 *
 * Creates an link to edit a item. 
 *
 *@params ItemSKU the items sku
 *@params ItemID  the items id (both are needed!!)
 *@params class   css class for formatting the link, optional 
 *@return htmlstring with link
 */

function smarty_function_pncEditItemLink($params, &$smarty)
{
    extract($params);
    unset($params);

    if( !isset($ItemID ) )
    {
        $smarty->trigger_error( "pncEditItemLink: missing parameter ItemID", E_USER_ERROR );
    }
    if( !isset($ItemSKU ) )
    {
        $smarty->trigger_error( "pncEditItemLink: missing parameter ItemSKU", E_USER_ERROR );
    }

    if( !pnSecAuthAction(0, 'pncommerce::item', $ItemSKU."::".$ItemID, ACCESS_ADMIN) )
    {
        return "";
    }
    $class = ( isset($class) ) ? "class='$class'" : ""; 
    return "<a $class href='".pnModURL( 'pncommerce', 'admin', 'itemedit', array( 'Mode' => 'edit', 'IID' => $ItemID ) )."'>".pnVarPrepForDisplay(_PNC_EDIT)."</a>"; 
    
}
?>
